// The NSpring Framework for .NET
// Copyright (c) 2003, Jeffrey Varszegi
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modification, 
// are permitted provided that the following conditions are met:
// 
// - Redistributions of source code must retain the above copyright notice, this 
// list of conditions and the following disclaimer.
// 
// - Redistributions in binary form must reproduce the above copyright notice, this 
// list of conditions and the following disclaimer in the documentation and/or other 
// materials provided with the distribution.
// 
// - Neither the name of the NSpring project nor the names of its contributors may 
// be used to endorse or promote products derived from this software without 
// specific prior written permission from the copyright owner.
// 
// - No product derived from this software may be called "NSpring", nor may 
// "NSpring" appear in the name of such a product, without specific prior written 
// permission from the copyright owner.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
// OF THE POSSIBILITY OF SUCH DAMAGE. 

namespace NSpring.Logging.Common {

using System;

/// <summary>
/// <para>
/// Contains constant values used by various loggers and formatters.
/// This code is not designed to be called directly from application code, and 
/// is subject to change without warning or deprecation.
/// </para>
/// </summary>
internal sealed class Constants {
    /// <summary>
    /// The ISO 8601 standard time zone specification, showing hours offset from GMT (ex.: "-04:00")
    /// The value returned is correct for the local environment for all dates not in daylight savings time
    /// </summary>
    internal static readonly string ISO_8601_TIME_ZONE                    = (new DateTime(2000, 7, 1)).ToString("zzz");
    /// <summary>
    /// The ISO 8601 standard time zone specification, showing hours offset from GMT (ex.: "-04:00").
    /// The value returned is correct for the local environment for all dates in daylight savings time
    /// </summary>
    internal static readonly string ISO_8601_DAYLIGHT_SAVINGS_TIME_ZONE   = (new DateTime(2000, 1, 1)).ToString("zzz");
    
    internal static readonly Version VERSION            = new Version(1, 1);

    private static string[] dateStrings                 = new string[61];
    private static string[] millisecondStrings          = new string[1000];
    private static string[] yearStrings                 = new string[2101];
    
    private static string[] monthNames                  = {
        "", "January", "February", "March", "April", "May", "June", 
        "July", "August", "September", "October", "November", "December"
    };
    private static string[] monthShortNames             = {
        "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
    };
    
    private static string[] weekdayNames                = {
        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
    };
    private static string[] weekdayShortNames           = {
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
    };
    
    /// <summary>
    /// The full names of all 12 months
    /// </summary>
    internal static string[] MonthNames {
        get {
            string[] source = monthNames;
            string[] returnValue = new string[source.Length];
            Array.Copy(source, 0, returnValue, 0, returnValue.Length);
            return returnValue;
        }
    }
    
    /// <summary>
    /// The short names of all 12 months
    /// </summary>
    internal static string[] MonthShortNames {
        get {
            string[] source = monthShortNames;
            string[] returnValue = new string[source.Length];
            Array.Copy(source, 0, returnValue, 0, returnValue.Length);
            return returnValue;
        }
    }
    
    /// <summary>
    /// The full names of all weekdays
    /// </summary>
    internal static string[] WeekdayNames {
        get {
            string[] source = weekdayNames;
            string[] returnValue = new string[source.Length];
            Array.Copy(source, 0, returnValue, 0, returnValue.Length);
            return returnValue;
        }
    }
    
    /// <summary>
    /// The short names of all weekdays
    /// </summary>
    internal static string[] WeekdayShortNames {
        get {
            string[] source = weekdayShortNames;
            string[] returnValue = new string[source.Length];
            Array.Copy(source, 0, returnValue, 0, returnValue.Length);
            return returnValue;
        }
    }
    
    static Constants() {
        int x;
        string prefix;
        
        prefix = "00";
        for(x = 0; x < 10; x++) {
            millisecondStrings[x] = prefix + x;
        }
        prefix = "0";
        for(x = 10; x < 100; x++) {
            millisecondStrings[x] = prefix + x;
        }
        for(x = 100; x < 1000; x++) {
            millisecondStrings[x] = x.ToString();
        }

        prefix = "0";
        for(x = 0; x < 10; x++) {
            dateStrings[x] = prefix + x;
        }
        for(x = 10; x <= 60; x++) {
            dateStrings[x] = x.ToString();
        }
        
        for(x = 1900; x <= 2100; x++) {
            yearStrings[x] = x.ToString();
        }
    }
    
    private Constants() {}
    
    internal static string[] DateStrings {
        get {
            return dateStrings;
        }
    }
    
    internal static string[] MillisecondStrings {
        get {
            return millisecondStrings;
        }
    }
    
    internal static string[] YearStrings {
        get {
            return yearStrings;
        }
    }

}

}
